﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.SqlClient;

public partial class admin_changeConfig : System.Web.UI.Page
{
    DB DBAdmin = new DB();
    int checkip = 0;
    int checktm = 0;

    protected void Page_Load(object sender, EventArgs e)
    {
        string strConfig = "select * from voteConfig where configId=1";
        SqlDataReader sdrConfig = DBAdmin.getSdr(strConfig);
        if (sdrConfig.Read())
        {
            if (sdrConfig.GetInt32(1) > 0)
            {
                CheckBox1.Checked = true;
                TextBox1.Text = sdrConfig.GetInt32(2).ToString();
            }
        }
        sdrConfig.Close();
    }

    protected void Button1_Click(object sender, EventArgs e)
    {
        checkip = 0;
        checktm = 0;
        if (CheckBox1.Checked == true)
        {
             checkip = 1;
            if (TextBox1.Text != "")
            {
              checktm = 12;
            }
             string configUpdate = "update voteConfig set voteIP='1',voteTime='" + checktm + "'where configId=1";
            DBAdmin.executeGetReturn(configUpdate);
            CheckBox1.Checked = false;
        }
         else
         {
             string configUpdate = "update voteConfig set voteIP='0',voteTime='0'where configId=1";
             DBAdmin.executeGetReturn(configUpdate);
         }
        Response.Redirect("mana.aspx");
    }
}
